package com.zz.hhbl.ui

import com.zz.framework.core.ext.printJson
import com.zz.framework.core.ext.toJson
import com.zz.framework.core.http.XBaseViewModel
import com.zz.framework.core.toast.ToastUtils
import com.zz.hhbl.config.GlobalCache
import com.zz.hhbl.model.CommonHttpRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

/**
 * Copyright © 2025 zhun All rights reserved.
 * Created by ZhaoZhun on 2025/2/17 22:09.
 * @author: ZhaoZhun 1820022519@qq.com
 * @version: V1.0
 */
@HiltViewModel
internal class MainViewModel @Inject constructor(private var repository: CommonHttpRepository) : XBaseViewModel() {
    fun login() {
        quickLaunch {
            repository.login(
                hashMapOf(
                    "username" to "123456",
                    "password" to "b829dba7bf115ea637d49d0eb5b05f05",
                    "code" to "123456",
                    "version" to "zh-CN",
                    "lang" to "zh-CN"
                )
            ).onSuccess {
                GlobalCache.setToken(it)
                ToastUtils.show(it?.toJson())
            }.onFailure {
                it.printJson()
                ToastUtils.show(it.toJson())
            }
        }
    }
}

